// pages/my/order.js
const app = getApp();
var com = require("../../utils/util.js");
var page = 1;
var total_page = 0;
var status = 0;
Page({
  /**
   * 页面的初始数据
   */
  data: {
    list : [],
    min_height: 0,
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (e) {
    status = e.id;
    var sync = wx.getSystemInfoSync();
    this.setData({
      min_height: sync.windowHeight
    })
    com.post('Api/Home/order_list', { status: status, page: page }, "setContent", this);
  },
  setContent: function (e) {
    total_page = e.total;
    this.setData({
      list: this.data.list.concat(e.lists),
    });
  },
  /**
   * 下拉显示更多
   */
  onList: function () {
    page = page + 1;
    if (total_page >= page) {
      com.post('Api/Home/order_list', { status: status, page: page }, "setContent", this);
    }
  },
  /**
   * 跳转到订单详情
   */
  goDetails : function(e){
    wx.navigateTo({
      url: "order_details?id=" + e.currentTarget.dataset.id,
    })
  },
  /**
   * 关闭页面，页面归1。防止下次进入页面出错
   */
  onUnload: function () {
    page = 1;
  }
})